import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import Hljs from 'highlight.js'

export default defineNuxtPlugin(async NuxtApp => {
  // nuxtApp包含的属性可看文档 https://nuxt.com/docs/guide/going-further/internals

  // 全局组件引入
  for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
    NuxtApp.vueApp.component(key, component)
  }

  NuxtApp.vueApp.directive('highlight', function (el) {
    const blocks = el.querySelectorAll('pre code')
    blocks.forEach((block: any) => {
      Hljs.highlightBlock(block)
    })
  })
})
